<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label">保险类型</label>
            <div class="layui-input-block">
            <select class="layui-select" name="insurance" required lay-filter="insurance">
                <option value="">请选择保险类型</option>
                {foreach $insurances as $k=>$v}               
                <option value="{$k}">{$v}</option>
                {/foreach}
            </select>
            </div>
        </div>
        
        <div class="layui-form-item" >
            <label class="layui-form-label">起始日期</label>
            <div class="layui-input-block">
                <input data-date-input="" name="start_date" value="" required
                placeholder="请选择"
                class="layui-input" autocomplete="off">
            </div>
        </div>  
        
        <div class="layui-form-item" >
            <label class="layui-form-label">社保工资</label>
            <div class="layui-input-block">
                <input  name="wage" value="" required placeholder="请输入"
                class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">公司基数</label>
            <div class="layui-input-block">
                <input  name="company_base" value="" readonly placeholder="请输入"
                class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">个人基数</label>
            <div class="layui-input-block">
                <input  name="personal_base" value="" readonly placeholder="请输入"
                class="layui-input" >
            </div>
        </div>
        

    </div>

    <div class="layui-form-item text-center" style="padding-left:40px">
		<button class="layui-btn layui-btn-cancel" type='button' data-close>取消</button>
        <button class="layui-btn" type='submit'>确定</button>
        <input type="hidden" name="increase_id" id="increase_id" value="{$id}" />
      
    </div>
    <script>
    	window.form.render();
        $(document).ready(function(){
            $("[name='wage']").change(function(){
              var wage=$(this).val(),
                  insurance =$("[name='insurance']").val();
                  if(wage&&insurance){
                    getBase(wage,insurance)
                  }
               
            })
            form.on('select(insurance)', function(data){
                var wage=$("[name='wage']").val(),
                  insurance =data.value;
                  if(wage&&insurance){
                    getBase(wage,insurance)
                  } 

            });
            function getBase(wage,insurance){
                $.form.load('{:url("index/staff/insuranceBase")}', {wage: wage,insurance:insurance}, "post", function (ret) {
                    if (ret.code === 1) {
                        $("[name='company_base']").val(ret.data.company)
                        $("[name='personal_base']").val(ret.data.personal)
                    } else {
                        $.msg.error(ret.info, 1)
                    }
                    return false;
                })
            }
        })
    </script>
</form>
